<?php
/**
 * This file initializes everything important.
 * Most importantly, it fires the prodigy_init() function,
 * which is essentially the earliest executed Prodigy hook.
 *
 * @author Nathan Rice
 * @package Prodigy
 **/

/**
 * theme/template data set in arrays for use in the theme
 * use print_r($theme_info) or print_r($template_info) to see the array items.
 *
 * $template_info represents the framework (Prodigy)
 * $theme_info represents the child theme, if one exists
 * 
 * @since 0.1
 */
$theme_info = get_theme_data(STYLESHEETPATH.'/style.css');
$template_info = get_theme_data(TEMPLATEPATH.'/style.css');

//load_theme_textdomain('prodigy');

/**
 * This is the only non-optional include
 * The theme won't work without the hooks
 *
 * @since 0.1
 */
include_once(TEMPLATEPATH.'/lib/hooks.php');

/**
 * Use this array (via a filter) to set constants. These constants
 * can be used throughout the framework and child themes.
 *
 * @since 0.1
 */
add_action('prodigy_init','prodigy_constants');
function prodigy_constants() {
	$constants = array(
		'LIBPATH' => TEMPLATEPATH.'/lib',
		'WP_CONTENT_URL' => get_bloginfo('wpurl').'/wp-content',
		'WP_CONTENT_DIR' => ABSPATH.'/wp-content',
		'TEMPLATEDIR' => get_bloginfo('template_directory'),
		'STYLESHEETDIR' => get_bloginfo('stylesheet_directory')
	);
	$constants = apply_filters('prodigy_constants',$constants);
	foreach($constants as $constant => $value) {
		if(!defined($constant)) define($constant, $value);
	}
}

/**
 * Use this array (via a filter) to do our includes. This is where
 * all of the Prodigy library files are loaded into the framework.
 *
 * @since 0.1
 */
//	include files based on the filterable $includes array
add_action('prodigy_init','prodigy_includes');
function prodigy_includes() {
	$includes = array(
		'structure' => LIBPATH.'/layout/structure.php',
		'elements' => LIBPATH.'/layout/elements.php',
		'loop_logic' => LIBPATH.'/loops/loop_logic.php',
		'loops' => LIBPATH.'/loops/loops.php',
		'feed_functions' => LIBPATH.'/functions/feed_functions.php',
		'seo_functions' => LIBPATH.'/functions/seo_functions.php',
		'widget_area_functions' => LIBPATH.'/functions/widget_area_functions.php',
		'general_functions' => LIBPATH.'/functions/general_functions.php',
		'admin_menu_functions' => LIBPATH.'/functions/admin_menu_functions.php',
		'legacy' => LIBPATH.'/legacy/legacy.php'
	);
	//	lets a child theme add or remove includes by
	//	modifying the array and returning it
	$includes = apply_filters('prodigy_includes',$includes);
	foreach($includes as $include) {
		include_once($include);
	}
}

/**
 * The first Prodigy hook to actually execute.
 *
 * @since 0.1
 */
prodigy_init(); //	gentlemen, start your engines
?>